package com.challenge;

import com.alibaba.fastjson.JSONArray;
import com.challenge.Constants.IConstants;
import com.challenge.Kitchen.Kitchen;
import com.challenge.Order.Orders;
import com.challenge.Action.DriverDispatcherProcess;
import com.challenge.Action.PlaceOrderProcess;

public class App
{
    public static boolean flag = true;

    public static void main( String[] args )
    {
        //init orders data
        Orders orders = new Orders();
        JSONArray ordersArray = orders.initOrders();
        String[] typeArray = new String[]{IConstants.COLD, IConstants.FROZEN, IConstants.HOT, IConstants.OVERFLOW, IConstants.TRASH};
        Integer[] sizeArray = new Integer[]{15, 15, 15, 20, Integer.MIN_VALUE};
        Kitchen kitchen = new Kitchen(typeArray, sizeArray);
        //receive an order every quarter second, make the order (instant), then place the order on its correct shelf
        PlaceOrderProcess placeOrder = new PlaceOrderProcess();
        placeOrder.placeOrder(ordersArray,kitchen);

        try {
            while (App.flag){
                Thread.sleep(10);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //kitchen.kitchenShow();

        kitchen.getSortShelf().shelfLifeCompute();//record all order's shelfLife
        kitchen.getSortShelf().sort();

        DriverDispatcherProcess driverOrdersProcess = new DriverDispatcherProcess();
        driverOrdersProcess.driverDispatcher(kitchen);

    }




}
